﻿using Application.InfoService;
using Domain.Entity.sys;
using Domain.Entity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WMSManage.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]//需要鉴权
    public class InfoController : ControllerBase
    {
        private readonly IInfoService infoService;

        public InfoController(IInfoService infoService)
        {
            this.infoService = infoService;
        }


        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="text"></param>
        /// <param name="type"></param>
        /// <param name="status"></param>
        /// <param name="CurrentPage"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<FenYe<Info>> GetInfo(string? text, string? type, int? status,int CurrentPage)
        {
            FenYe<Info> fenYe = new FenYe<Info>
            {
                CurrentPage = CurrentPage,
            };
            return await infoService.GetInfo(fenYe, text, type, status);
        }


        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeleteInfo(int id)
        {
            return await infoService.DeleteInfo(id);
        }



        /// <summary>
        /// 修改信息状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateStatus(int id, int status)
        {
            return await infoService.UpdateStatus(id, status);
        }
    }
}
